<template>
    <div class="income-template" v-bind:dataValue="showLoading">
        <yd-navbar slot="navbar" title="员工信息" class="public-header">
            <span slot="left">
                <a href="javascript:window.history.go(-1)"><yd-navbar-back-icon></yd-navbar-back-icon></a>
            </span>
        </yd-navbar>
        <yd-slider autoplay="3000">
            <yd-slider-item v-for="item in list.detail_pic">
                <a href="javascript:;">
                    <img :src="item.image">
                </a>
            </yd-slider-item>
        </yd-slider>
        <div class="income-content">
            <h3 class="income-title">员工列表 [ 店铺：{{list.shop_name}} ]</h3>
        </div>
        <yd-list theme="1">
            <yd-list-item v-for="item in list.data">
                <img slot="img" :src="item.avatar.image">
                <span slot="title">{{item.name}} {{item.job}} {{item.education}}</span>
                <yd-list-other slot="other">
                    <div>
                        <p>入职时间 {{item.enter_time}}</p>
                    </div>
                </yd-list-other>
            </yd-list-item>
        </yd-list>
        <yd-tabbar slot="tabbar" class="public-footer">
            <yd-tabbar-item title="首页" link="/">
                <yd-icon name="home" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="投资收益" link="/income" active>
                <yd-icon name="shopcart-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="信息交流" link="/message">
                <yd-icon name="like-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="个人中心" link="/user">
                <yd-icon name="ucenter-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
        </yd-tabbar>
    </div>
</template>
<script>
    import Ajax from "../api/ajax.js"
    import dataURL from "../data/dataURL.js"
    export default {
        data() {
            return {
                queryID: '',
                loadBloean:true,
                list: {
                    cover_pic: [],
                    intro: "",
                    shop_name: "",
                    data: [{
                        avatar: {
                            image: "",
                            image_path: "",
                        },
                        "staff_id": 1,
                        "name": "aaa1234", //员工姓名
                        "education": "aaa12345",// 学历
                        "job": "aaa12345", //职位
                        "enter_time": "2011-11-11",// 入职时间
                    }]
                }
            }
        },
        methods: {
            async getData() {
                this.queryID = this.$route.query.id;
                let res = await Ajax.Post(dataURL.income.stafflist, {
                    shop_id: this.queryID
                });
                // 虚拟员工头像
                for (let item of res.data) {
                    item.avatar = {
                        image: "http://img1.shikee.com/try/2016/06/19/09430120929215230041.jpg"
                    }
                }
                this.list = res;
                this.loadBloean = false;
            }
        },
        computed: {
            showLoading() {
                if (this.loadBloean) {
                    this.$dialog.loading.open('很快加载好了');
                } else {
                    this.$dialog.loading.close();
                }
            }
        },
        mounted() {
            this.getData();
        }

    }

</script>